/*
 * gpt.c
 *  Arizona State University
 *  CSE 325: Embedded Systems Programming
 *  Lab 7: Morse Code
 *  Georgii Tkachuk, Brentton Garber
 *   Emails: 	gtkachuk@asu.edu btgarber@asu.edu
 *      Description: Initializes Two buttons. Button 1: Resets the pattern to start from step 0.
 *      									  Button 2: Changes the pattern to all zeros. All timers and transfers will still be happening but the screen will be empty.
 */

#include "common.h"

// Initialize the GPTs
void gpt_init()
{
	// NUMBER 1 NEEDS TO BE LOOKED INTO
	MCF_GPIO_PTAPAR |= 1; 		//# 1 Configure the pin to perform GPT function.
	MCF_GPT_GPTIOS &= ~(7); // # 2
	MCF_GPT_GPTCTL2 |= MCF_GPT_GPTCTL2_EDG0A; // # 3
	MCF_GPT_GPTCTL2 &= ~MCF_GPT_GPTCTL2_EDG0B;
	MCF_GPIO_DDRTA &= 0 ;//~(1);
	MCF_GPT_GPTDDR &= ~(15); // # 4
	MCF_GPT_GPTIE |= 1; // # 5
	MCF_GPT_GPTSCR1 |= 1 << 7; // # 6
	set_gpt_handler(64+44, gpt_handler);
	
	MCF_GPIO_PTAPAR |= 4; 		//# 1 Configure the pin to perform GPT function.
	MCF_GPT_GPTCTL2 |= MCF_GPT_GPTCTL2_EDG1A; // # 3
	MCF_GPT_GPTCTL2 &= ~MCF_GPT_GPTCTL2_EDG1B;
	MCF_GPT_GPTIE |= 2; // # 5
	MCF_GPT_GPTSCR1 |= 1 << 7; // # 6
	set_gpt_handler_1(64+45, gpt_handler_1);
	
}